package com.szmg.auth.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.szmg.auth.model.User;
import com.szmg.common.BaseDao;

@Component("userDao")
public class UserDao extends BaseDao {

	
	public List<User> findAllUser() {
		return this.readSqlSession.selectList("com.szmg.auth.dao.UserDao.selectAllUser");
	}
	
	public List<User> findUser(int start,int size,User user) {
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("start", start);
		map.put("size", size);
		map.put("user", user);
		return this.readSqlSession.selectList("com.szmg.auth.dao.UserDao.selectUser",map);
	}
	
	public void addUser(User user){
		writerSqlSession.insert("com.szmg.auth.dao.UserDao.addUser", user);
	}
	
	public User findUserById(int id){
		return readSqlSession.selectOne("com.szmg.auth.dao.UserDao.selectUserById", id);
	}
	public void deleteUserById(int id){
		writerSqlSession.delete("com.szmg.auth.dao.UserDao.deleteUserById", id);
	}
}
